<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Generate Score Report</title>
<link rel="stylesheet" type="text/css" href="css/FinalProjectCSS.css"/>
<script type="text/javascript">
	function flyToPage(task) {
		document.forms[0].target = '';
		document.forms[0].task.value = task;
		document.forms[0].submit();
	}
	function showParamCombo(status) {
		document.forms[0].target = '';
		//var reportType = document.getElementsByName('reportType')[0].value;
		document.forms[0].batchChangeStatus.value = status;
		document.forms[0].task.value = 'showParamCombo';
		document.forms[0].submit();
	}
	function reportTypeChange() {
		document.forms[0].target = '';
		var reportType = document.getElementsByName('reportType')[0].value;
		if(reportType=='1'){
			document.getElementById('batchParam').style.display = '';
			document.getElementById('subjectParam').style.display = 'none';
			document.getElementById('traineeParam').style.display = 'none';
			document.getElementById('batchTypeParam').style.display = '';
			document.getElementById('reportBtn').style.display = '';
		}else if(reportType=='2'){
			document.getElementById('batchParam').style.display = '';
			document.getElementById('traineeParam').style.display = '';
			document.getElementById('subjectParam').style.display = 'none';
			document.getElementById('batchTypeParam').style.display = 'none';
			document.getElementById('reportBtn').style.display = '';
		}else if(reportType=='3'){
			document.getElementById('batchParam').style.display = '';
			document.getElementById('traineeParam').style.display = 'none';
			document.getElementById('subjectParam').style.display = '';
			document.getElementById('batchTypeParam').style.display = 'none';
			document.getElementById('reportBtn').style.display = '';
		}else if(reportType=='4'){
			document.getElementById('batchParam').style.display = 'none';
			document.getElementById('traineeParam').style.display = 'none';
			document.getElementById('subjectParam').style.display = 'none';
			document.getElementById('batchTypeParam').style.display = 'none';
			document.getElementById('graphBtn').style.display = '';
			document.getElementById('reportBtn').style.display = '';
		}else{
			document.getElementById('batchParam').style.display = 'none';
			document.getElementById('traineeParam').style.display = 'none';
			document.getElementById('subjectParam').style.display = '';
			document.getElementById('batchTypeParam').style.display = 'none';
			document.getElementById('reportBtn').style.display = 'none';
			document.getElementById('graphBtn').style.display = '';
		}
	}
	function batchTypeBtn() {
		document.forms[0].target = '';
		if(document.getElementsByName('batchTypeParam')[0].value=='2'){
			document.getElementById('reportBtn').style.display = 'none';
		}else{
			document.getElementById('reportBtn').style.display = '';
		}
	}
	function newWindow(task) {
		document.forms[0].target = '_blank';
		document.forms[0].task.value = task;
		document.forms[0].submit();
	}
	function setSearchBatch() {
		var reload = document.forms[0].batchChangeStatus.value;
		if(reload=='0'){
			document.forms[0].batchParam.value = document.forms[0].searchBatch.value;
		}
	}
</script>
</head>
<body onload="javascript:reportTypeChange();setSearchBatch();">
	<center>
		<table width="1000px" class="bodyTable boxShadow">
		
			<!-- Header -->
			<tr>
				<td colspan="2"><%@include file="/include/Header.jsp"%></td>
			</tr>
		
			<!-- Content -->
			<tr>
				<td rowspan="2" width="200px" class="navigationBox"><%@include file="/include/Navigation.jsp"%></td>
				<td align="left" class="headerBox blueBackground">ACE Management > 
				<a href="/WebFinalProject/Score.do">ACE-Score</a>
				 > Generate Score Report</td>
			</tr>
			<tr>
				<td align="center"  class="contentStyle"><br>
				<html:form action="/Score" method="post">
				<html:hidden name="scoreForm" property="task"/>
				<html:hidden name="scoreForm" property="searchBatch"/>
				<html:hidden name="scoreForm" property="searchSubject"/>
				<html:hidden name="scoreForm" property="batchChangeStatus"/>
						<table width="50%" class="boxShadow">
							<tr class="headerBox formHeaderBackground">
								<td align="center" colspan="3" class="formListStyle">Generate Score Report</td>
							</tr>
							<tr>
								<td class="formListStyle" width="30%">Categorized By</td>
								<td class="formListStyle" width="10%" align="center">:</td>
								<td class="formListStyle">
									<html:select styleClass="textStretch" name="scoreForm" property="reportType" onchange="javascript:reportTypeChange()">
										<%if(!"trainee".equalsIgnoreCase(user.getRole())){ %>
											<%if("admin".equalsIgnoreCase(user.getRole())){ %> 
												<html:option value="1">Batch</html:option>
												<html:option value="2">Trainee</html:option>
												<html:option value="3">Subject</html:option>
											<%}else{ %>
												<html:option value="3">Subject</html:option>
										<%	  }
										  }else {%>
										  	<html:option value="4">Trainee</html:option>
											<html:option value="5">Subject</html:option>
										<%}%>
									</html:select>
								</td>
							</tr>
							<tr id="batchParam">
								<td class="formListStyle">Batch</td>
								<td class="formListStyle" align="center">:</td>
								<td class="formListStyle">
									<html:select styleClass="textStretch" name="scoreForm" property="batchParam" onchange="javascript:showParamCombo('1');">
										<logic:notEmpty name="scoreForm" property="listBatch">
											<html:optionsCollection name="scoreForm" property="listBatch" value="batchId" label="batchName"/>
										</logic:notEmpty>
									</html:select>
								</td>
							</tr>
							<tr id="subjectParam" >
								<td class="formListStyle">Subject</td>
								<td class="formListStyle" align="center">:</td>
								<td class="formListStyle">
									<html:select styleClass="textStretch" name="scoreForm" property="subjectParam">
										<logic:notEmpty name="scoreForm" property="listSubject">
											<html:optionsCollection name="scoreForm" property="listSubject" value="classId" label="className" />
										</logic:notEmpty>
										<logic:empty name="scoreForm" property="listSubject">
											<html:option value="">No Data</html:option>
										</logic:empty>
									</html:select>
								</td>
							</tr>
							<tr id="traineeParam">
								<td class="formListStyle">Trainee</td>
								<td class="formListStyle" align="center">:</td>
								<td class="formListStyle">
									<html:select styleClass="textStretch" name="scoreForm" property="traineeParam">
										<logic:notEmpty name="scoreForm" property="listTrainee">
											<html:optionsCollection name="scoreForm" property="listTrainee" value="traineeId" label="traineeNameList"/>
										</logic:notEmpty>
										<logic:empty name="scoreForm" property="listTrainee">
											<html:option value="">No Data</html:option>
										</logic:empty>
									</html:select>
								</td>
								<td id="batchTypeParam">
									<html:select name="scoreForm" property="batchTypeParam" onchange="javascript:batchTypeBtn();">
										<html:option value="1">Class</html:option>
										<html:option value="2">Group Class</html:option>
									</html:select>
								</td>
							</tr>
							<tr>
<!-- 								<td colspan="4" align="center"> -->
<!-- 									<input type="button" id="reportBtn" value="Get Report" style="width: auto;" onclick="javascript:newWindow('getReport');" /> -->
<!-- 									<input type="button" id="graphBtn"  value="View Graph" style="width: auto;" onclick="javascript:newWindow('viewGraph');" /> -->
<%-- 									<%if("admin".equals(user.getRole())){%> --%>
<!-- 										<input type="button" id="backBtn"  value="Back" style="width: auto;" onclick="javascript:flyToPage('manageScore');" /> -->
<%-- 									<%}%> --%>
								<td colspan="3" align="center">
<!-- 									<input type="button" value="Get Report" style="width: auto;" onclick="javascript:flyToPage('getReport');" /> -->
<!-- 									<input type="button" value="View Graph" style="width: auto;" onclick="javascript:flyToPage('viewGraph');" /> -->
									<table>
										<tr>
											<td align="right" class="formListStyle" width="50%">
												<table id="reportBtn" title="view report" class="buttonStyle" style="cursor: pointer; width:100px;" onclick="javascript:newWindow('getReport');">
													<tr>
														<td style="vertical-align:middle;"><img src="images/reportButton.png"/></td>
														<td style="vertical-align:middle;"><b>View Report&nbsp;</b></td>
													</tr>
												</table>
											</td>
											<td align="left" class="formListStyle" width="50%">			
												<table id="graphBtn" title="view graph" class="buttonStyle" style="cursor: pointer; width:100px;" onclick="javascript:newWindow('viewGraph');">
													<tr>
														<td style="vertical-align:middle;"><img src="images/chartButton.png"/></td>
														<td style="vertical-align:middle;"><b>View Chart&nbsp;</b></td>
													</tr>
												</table>
											</td>
											<%if("admin".equals(user.getRole())){%>
											<td align="center" class="formListStyle">
												<table title="back" class="buttonStyle" style="cursor: pointer;" onclick="javascript:flyToPage('listScore');">
													<tr>
														<td style="vertical-align:middle;"><img src="images/backButton.png"/></td>
														<td style="vertical-align:middle;"><b>Back</b></td>
													</tr>
												</table>
											</td>
											<%} %>
										</tr>
										<%-- <%if("admin".equals(user.getRole())){%>
										<tr align="center">
											<td colspan="3" class="formListStyle">
												<table title="back" style="cursor: pointer;" onclick="javascript:flyToPage('listScore');">
													<tr>
														<td style="vertical-align:middle;"><img src="images/backButton.png"/></td>
														<td style="vertical-align:middle;"><b>&nbsp;Back&nbsp;</b></td>
													</tr>
												</table>
											</td>
										</tr>
										<%} %> --%>
									</table>
								</td>
							</tr>
						</table>
				</html:form>
					<br>
				</td>
			</tr>
			
			<!-- Footer -->
			<tr>
				<td align="center" colspan="2" class="headerBox blueBackground">&copy; OME. 2013. All Rights Reserved.</td>
			</tr>
		</table>
	</center>
</body>
</html>